package cn.t.web.user;

import cn.t.core.controller.BaseController;
import cn.t.dto.user.CostCenterDTO;
import cn.t.facade.user.CostCenterFacade;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;

/**
 * 场景信息表服务入口
 *
 * @author l
 */
@Slf4j
@RestController
@RequestMapping("costCenter")

@AllArgsConstructor
public class CostCenterController extends BaseController<CostCenterDTO, CostCenterFacade> {


    @PostMapping("save")
    @Override
    public Boolean save(@Valid @RequestBody CostCenterDTO dto) {
        return facade.add(dto);
    }



    @PostMapping("findByFirm")
    public List<CostCenterDTO> findByFirm(Long[] firmIds) {
        if (firmIds == null || firmIds.length == 0) {
            return null;
        }
        return facade.findByFirm(Arrays.asList(firmIds));
    }
}

